import com.mysql.cj.jdbc.MysqlDataSource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCDemo {
    public static void main(String[] args) throws SQLException {
        //1.先创建 DataSource对象
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource) dataSource).setUrl("jdbc:mysql://120.76.247.29:3306/infoflow?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai");
        ((MysqlDataSource) dataSource).setUser("infoflow");
        ((MysqlDataSource) dataSource).setPassword("infoflow");
        //2.建立和数据库服务器之间的连接，连接好了之后，才能进行后续的 请求-相应 交互
        Connection connection = dataSource.getConnection();
        //3.构建SQL语句，代码中的SQL语句不需要写";"
        String sql1 = "SELECT * from access_user_reg where user_phone_md5 = md5('17392755291')";
        PreparedStatement statement = connection.prepareStatement(sql1);
        //4.将SQL发送给数据库服务器
        ResultSet resultSet = statement.executeQuery();
//        System.out.println(resultSet.next() + "-----------------");
        String first_code = resultSet.getString(3);
        if (first_code == "1000000000017760" && first_code != null){
            ;
        }else {
            //钉钉预警
        }

        statement.close();
        connection.close();
    }
}

